package com.direct.ssh.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.ParamDef;

/**
 * Employee entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "T_EMPLOYEE", schema = "OA")
@FilterDef(name="validFilter", parameters=@ParamDef(type="integer", name="valid"))
@Filter(name="validFilter",condition="valid=:valid")
public class Employee implements java.io.Serializable,com.direct.ssh.domain.Entity {

	// Fields

	private String id;
	private Department department;
	private String code;
	private String name;
	private String gender;
	private String phone1;
	private String phone2;
	private String address;
	private String qq;
	private String email;
	private Date birthday;
	private Date hiredate;
	private Integer sal;
	private String job;
	private String remark;
	private Integer valid;
	private Account account;
	private Set<Work> worksForCreator = new HashSet<Work>(0);
	private Set<Work> worksForWorker = new HashSet<Work>(0);
	private Set<Department> departments = new HashSet<Department>(0);

	// Constructors

	/** default constructor */
	public Employee() {
	}

	/** full constructor */
	public Employee(Department department, String code, String name,
			String gender, String phone1, String phone2, String address,
			String qq, String email, Date birthday, Date hiredate,
			Integer sal, String job, String remark, Integer valid,
			Account account, Set<Work> worksForCreator,
			Set<Work> worksForWorker, Set<Department> departments) {
		this.department = department;
		this.code = code;
		this.name = name;
		this.gender = gender;
		this.phone1 = phone1;
		this.phone2 = phone2;
		this.address = address;
		this.qq = qq;
		this.email = email;
		this.birthday = birthday;
		this.hiredate = hiredate;
		this.sal = sal;
		this.job = job;
		this.remark = remark;
		this.valid = valid;
		this.account = account;
		this.worksForCreator = worksForCreator;
		this.worksForWorker = worksForWorker;
		this.departments = departments;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "ID", unique = true, nullable = false, length = 36)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "DEPART_ID")
	public Department getDepartment() {
		return this.department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	@Column(name = "CODE", length = 20)
	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "NAME", length = 20)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "GENDER", length = 6)
	public String getGender() {
		return this.gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	@Column(name = "PHONE1", length = 15)
	public String getPhone1() {
		return this.phone1;
	}

	public void setPhone1(String phone1) {
		this.phone1 = phone1;
	}

	@Column(name = "PHONE2", length = 15)
	public String getPhone2() {
		return this.phone2;
	}

	public void setPhone2(String phone2) {
		this.phone2 = phone2;
	}

	@Column(name = "ADDRESS", length = 300)
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "QQ", length = 15)
	public String getQq() {
		return this.qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	@Column(name = "EMAIL", length = 200)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "BIRTHDAY", length = 7)
	public Date getBirthday() {
		return this.birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "HIREDATE", length = 7)
	public Date getHiredate() {
		return this.hiredate;
	}

	public void setHiredate(Date hiredate) {
		this.hiredate = hiredate;
	}

	@Column(name = "SAL", precision = 22, scale = 0)
	public Integer getSal() {
		return this.sal;
	}

	public void setSal(Integer sal) {
		this.sal = sal;
	}

	@Column(name = "JOB", length = 20)
	public String getJob() {
		return this.job;
	}

	public void setJob(String job) {
		this.job = job;
	}

	@Column(name = "REMARK", length = 500)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "VALID", precision = 22, scale = 0)
	public Integer getValid() {
		return this.valid;
	}

	public void setValid(Integer valid) {
		this.valid = valid;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "employee")
	public Account getAccount() {
		return this.account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "creator")
	public Set<Work> getWorksForCreator() {
		return this.worksForCreator;
	}

	public void setWorksForCreator(Set<Work> worksForCreator) {
		this.worksForCreator = worksForCreator;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "worker")
	public Set<Work> getWorksForWorker() {
		return this.worksForWorker;
	}

	public void setWorksForWorker(Set<Work> worksForWorker) {
		this.worksForWorker = worksForWorker;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "employee")
	public Set<Department> getDepartments() {
		return this.departments;
	}

	public void setDepartments(Set<Department> departments) {
		this.departments = departments;
	}

}